package cn.com.zhangwoo.microstar.homepage.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import cn.com.microstar.activity.R;
import cn.com.zhangwoo.microstar.adapter.ListSuperMarketAdapter;
import cn.com.zhangwoo.microstar.adapter.SupermarketGridViewAdapter;
import cn.com.zhangwoo.microstar.inteface.IUtilDB;
import cn.com.zhangwoo.microstar.utildb.AppManager;
/***
 * 超市分类
 * @author Administrator
 *
 */
public class SupermarketClassificationActivity extends Activity implements OnClickListener{
	
		private GridView mGridView;
		private ListView mListView;
		private TextView mTextViewTitle;
		private ImageView mImageView;
		private ListSuperMarketAdapter adapterList;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			// TODO Auto-generated method stub
			super.onCreate(savedInstanceState);
			AppManager.getInstance().addActivity(SupermarketClassificationActivity.this);
			setContentView(R.layout.activity_supermarketcalassfication);
			initView();
		}
		
		private void initView() {
			findViewById(R.id.signin_actionbar_title_img).setOnClickListener(this);
			mTextViewTitle=(TextView) findViewById(R.id.signin_actionbar_title_text);
			mTextViewTitle.setText("超市分类");
			mImageView=(ImageView) findViewById(R.id.signin_actionbar_xname_img);
			mImageView.setImageDrawable(getResources().getDrawable(R.drawable.android_arrow_message3));
			mImageView.setOnClickListener(this);
			mListView=(ListView) findViewById(R.id.supermarket_listView);
			mGridView=(GridView) findViewById(R.id.activity_supermarket_gridview);
			mGridView.setAdapter(new SupermarketGridViewAdapter(SupermarketClassificationActivity.this, IUtilDB.img));
			loadData();
			
		}
		
		private void loadData() {
			String[] superName=getResources().getStringArray(R.array.supermarket_array);
			adapterList=new ListSuperMarketAdapter(SupermarketClassificationActivity.this, superName);
			mListView.setAdapter(adapterList);
			mListView.setOnItemClickListener(listAdapter);
			mGridView.setOnItemClickListener(gridAdapter);
		}
		
		
		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.signin_actionbar_title_img:
				SupermarketClassificationActivity.this.finish();
				break;
			case R.id.signin_actionbar_xname_img:
				
				break;
			default:
				break;
			}
			
		}
		
		OnItemClickListener listAdapter=new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				//TODO Auto-generated method stub
				Toast.makeText(getApplicationContext(), "=="+position, 1).show();
				adapterList.showOnclickTextBackGround(position);
				
			}
		};
		OnItemClickListener gridAdapter=new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				//TODO Auto-generated method stub
				Toast.makeText(getApplicationContext(), "=="+position, 1).show();
				
			}
		};

}
